package by.gravity.model;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

public class Week {

	private String specialityName;

	private String kursName;

	private String groupName;

	private List<Day> days;

	public Week() {
		days = new ArrayList<Day>();
	}

	public Week(String specialityName, String kursName, String groupName) {
		this();
		this.specialityName = specialityName;
		this.kursName = kursName;
		this.groupName = groupName;
	}

	public String getSpecialityName() {
		return specialityName;
	}

	public void setSpecialityName(String specialityName) {
		this.specialityName = specialityName;
	}

	public String getKursName() {
		return kursName;
	}

	public void setKursName(String kursName) {
		this.kursName = kursName;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public void addLesson(Date date, String timeStart, String timeFinish, String teacherName, String lessonName, String auditoryName) {
		getDay(date).addLesson(new Lesson(timeStart, timeFinish, teacherName, lessonName, auditoryName));
	}

	public void addLesson(Date date, Lesson lesson) {
		Day day = getDay(date);
		day.addLesson(lesson);
	}

	private Day getDay(Date date) {
		for (Day day : days) {
			if (day.getDate().equals(date)) {
				return day;
			}
		}
		Day dayInfo = new Day(date);
		days.add(dayInfo);
		return dayInfo;
	}

	public Lesson newLesson() {
		return new Lesson();
	}

	public List<Day> getDays() {
		return days;
	}

}